<template>
  <ul class="list-group">
    <li v-for="item in articles">
      <a :href="item.id" v-text="item.title"></a>
    </li>
  </ul>
</template>

<script>
  export default {
    data () {
      return {
        articles: [],
        action: 'articles'
      }
    },
    props: ['articleCategory'],
    mounted () {
      this.getArticles()
    },
    methods: {
      getArticles: function () {
        let that = this
        let apiUrl = process.env.API_URL + that.action + '?acid=' + that.articleCategory
        that.$http.get(apiUrl).then(function (response) {
          that.articles = response.body.items
        }, function (error) {
          console.log(error)
        })
      }
    }
  }
</script>
